package com.mall.service;

import com.mall.mapper.AdminMapper;
import com.mall.pojo.Active;
import com.mall.pojo.Admin;
import com.mall.pojo.Business;
import com.mall.pojo.Good;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    private AdminMapper mapper;


    @Override
    public Admin login(String acc,String pwd) {
        return mapper.login(acc,pwd);
    }



    @Cacheable(cacheNames = "good" ,key = "#pageSize")
    @Override
    public List<Good> showGoodPlus(String name, Integer pageSize, Integer offset) {
        System.out.println("走了数据库===============================================");
        return mapper.showGoodPlus(name,pageSize,offset);
    }

    @Override
    public Integer searchCountGood(String name) {
        return mapper.searchCountGood(name);
    }

    @Override
    @Cacheable(cacheNames = "Classify" ,key = "#pid")
    public List<Good> showGoodClassify(Integer pid, Integer pageSize, Integer offset) {
        System.out.println("走了数据库showGoodClassify===============================================");
        return mapper.showGoodClassify(pid,pageSize,offset);
    }

    @Override
    public Integer showGoodClassifyCount(Integer pid) {
        return mapper.showGoodClassifyCount(pid);
    }

    @Override
    public Integer backToPre(Integer pid) {

        //controller编写逻辑
        Integer currentPid=  mapper.backToPre(pid);
//        System.out.println("当前在service层的currentPid是"+currentPid);

        return currentPid;
    }

    @Override
    public List<Good> selectPreById(Integer currentPid) {
        return mapper.selectPreById(currentPid);
    }

    @Override
    public Boolean insertByPid(Integer pid, String goodName,String level) {
        return mapper.insertByPid(pid,goodName,level);
    }

    @Override
    public List<Business> showStorePlus(String name, String status, Integer pageSize, Integer offset) {
        return mapper.showStorePlus(name,status,pageSize,offset);
    }

    @Override
    public Integer showStorePlusCount(String name, String status) {
        return mapper.showStorePlusCount(name,status);
    }

    @Override
    public Boolean passToOne(Integer businessId) {
        return mapper.passToOne(businessId);
    }

    @Override
    public List<Good> searchAll() {
        System.out.println("你走到了");
        return mapper.searchAll();
    }

    @Override
    public String selectLevelByGId(Integer gid) {
        return mapper.selectLevelByGId(gid);
    }

    @Override
    public List<Active> showKillActive(String name, Integer pageSize, Integer offset) {
        return mapper.showKillActive(name,pageSize,offset);
    }

    @Override
    public Integer showKillActiveCount(String name) {
        return mapper.showKillActiveCount(name);
    }

    @Override
    public Boolean addKill(Active active) {
        return mapper.addKill(active);
    }


}
